public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public List<Integer> findAnagrams(String s, String p) {
        int[] hash1 = new int[26];
        int[] hash2 = new int[26];
        List<Integer> list = new ArrayList<>();
        int count = 0;
        int n = p.length();
        for (int i = 0;i < p.length();i++) {
            hash2[p.charAt(i)-97]++;
        }
        for (int right = 0,left = 0;right < s.length();right++) {
            //进窗口
            int in = s.charAt(right)-97;
            hash1[in]++;
            if (hash1[in]<=hash2[in]) {
                count++;
            }
            //出窗口
            if (right-left+1>n) {
                int out = s.charAt(left)-97;
                if (hash1[out]<=hash2[out]) count--;
                hash1[out]--;
                left++;
            }
            //更新结果
            if (count==n) {
                list.add(left);
            }
        }
        return list;
    }
}